<template>
	<view class="page-content">
		<view class="bg_fff mb-20">
			<u-tabs :list="typeList" @click="typeClick" lineColor="#333333"
				:activeStyle="{fontWeight: 'bold',color: '#333333',transform: 'scale(1.2)'}"
				:inactiveStyle="{color: '#999999'}"></u-tabs>
		</view>

		<uni-list style="padding:0 2%;box-sizing: border-box;padding-bottom: 40rpx;" :border="false"
			v-if="dataList.length">
			<view class="bg_fff mb-20 itemBox" @click="clickListItem(dataItem)" v-for="(dataItem, index) in dataList"
				:key="index">
				<view class="pd-20 display_row_btn_center" style="padding-right: 0;">
					<view class="itemBaseBox">
						<u-image :src="dataItem.cover" width="100rpx" height="100rpx"></u-image>
						<view class="itemBase f_24">
							<text class="c_333333 title">{{dataItem.name||""}}</text>
							<view class="c_333333 mt-8">总订单：<text
									class="c_C62B2C f_28">{{dataItem.order_count||0}}</text>
							</view>
							<view class="c_333333 mt-8">总收益：<text class="c_C62B2C f_28">￥{{dataItem.amount||0}}</text>
							</view>
						</view>
					</view>
				</view>
			</view>
		</uni-list>
		<u-empty mode="list" v-else :customStyle="{flex:'1'}"></u-empty>
	</view>
</template>

<script>
	import {
		getPlatform,
		getAuthMissions
	} from '@/config/api.js'

	export default {
		data() {
			return {
				userinfo: null,
				typeList: [],
				dataList: [],
				platform_flag: "all",
				page: 1,
				pages: 1
			}
		},
		created() {
			this.initData();
		},
		methods: {
			initData() {
				getPlatform().then((res) => {
					this.typeList = res;
				}).catch((err) => {

				});
				this.getMissionsData();
			},
			typeClick(data) {
				this.dataList = [];
				this.page = 1;
				this.pages = 1;
				this.platform_flag = data.flag;
				this.getMissionsData();
			},
			clickListItem(data) {
				uni.navigateTo({
					url: "/pages/center/order?id=" + data.id
				})
			},
			getMissionsData() {
				getAuthMissions({
					platform_flag: this.platform_flag,
					page: this.page
				}).then((res) => {
					this.dataList = this.dataList.concat(res.list);
					this.pages = res.page.pages;
					this.page++;
				}).catch((err) => {

				});
			},
			listScrollTolower() {
				if (this.page <= this.pages) {
					this.getMissionsData();
				}
			},
		}
	}
</script>

<style scoped>
	.itemBox {
		width: 100%;
		border-radius: 20rpx;
	}

	.itemBaseBox {
		display: flex;
		flex-direction: row;
		justify-content: flex-start;
		align-items: center;
		flex: 6;
	}

	.itemBase {
		display: flex;
		flex-direction: column;
		justify-content: flex-start;
		margin-left: 20rpx;
	}

	.title {
		font-size: 36rpx;
		font-weight: 600;
	}

	.status {
		border: 1px solid #C62B2C;
		border-radius: 10rpx;
		padding: 10rpx;
	}
</style>
